<!-- 功能：服务管理 | 作者：menghao.yan | 邮箱：yxs2615@163.com | 时间：2023年08月21日 23:38:55 -->
<template>
  <a-tabs v-model:activeKey="activeKey" type="card" class="y-tabs">
    <a-tab-pane key="sambaSheZhi" tab="SAMBA设置">
      <a-card>
        <a-row align="middle">
          <a-col :span="16">
            <a-space>
              <a-button type="link" class="y-btn" @click="openWindowsGongXiangQuanJuSheZhiModal">
                <template #icon>
                  <setting-outlined />
                </template>
                Windows共享全局设置
              </a-button>
              <!-- 弹窗 - Windows共享全局设置 -->
              <windowsGongXiangQuanJuSheZhiModal v-model:visible="visibleWindowsGongXiangQuanJuSheZhiModal"></windowsGongXiangQuanJuSheZhiModal>
              <a-button type="link" class="y-btn" @click="openBianJiWindowsGongXiangModal">
                <template #icon>
                  <setting-outlined />
                </template>
                编辑Windows共享
              </a-button>
              <!-- 弹窗 - 编辑Windows共享 -->
              <bianJiWindowsGongXiangModalfrom v-model:visible="visibleBianJiWindowsGongXiangModal"></bianJiWindowsGongXiangModalfrom>
              <a-button type="link" class="y-btn y-close-windows-gongXiang" @click="tingZhiWindowsGongXiangFuwu">
                <template #icon>
                  <poweroff-outlined />
                </template>
                停止Windows共享
              </a-button>
            </a-space>
          </a-col>
          <a-col :span="8">
            <a-input v-model:value="searchValueSambaSheZhi">
              <template #addonBefore>
                <search-outlined /> 搜索:
              </template>
            </a-input>
          </a-col>
        </a-row>
        <a-table bordered :data-source="dataSourceSambaSheZhi" :columns="columnsSambaSheZhi" :pagination="paginationSambaSheZhi" class="y-table"></a-table>
      </a-card>
    </a-tab-pane>

    <a-tab-pane key="nfsSheZhi" tab="NFS设置">
      <a-card>
        <a-row align="middle">
          <a-col :span="16">
            <a-space>
              <a-button type="link" class="y-btn" @click="openNfsShuChuModal">
                <template #icon>
                  <setting-outlined />
                </template>
                NFS输出
              </a-button>
              <!-- 弹窗 - NFS输出 -->
              <nfsShuChuModal v-model:visible="visibleNfsShuChuModal"></nfsShuChuModal>
              <a-button type="link" class="y-btn y-close-windows-gongXiang" @click="tingZhiUnixWenJianGongXiangFuWu">
                <template #icon>
                  <poweroff-outlined />
                </template>
                停止Unix文件共享服务
              </a-button>
            </a-space>
          </a-col>
          <a-col :span="8">
            <a-input v-model:value="searchValueNfsSheZhi">
              <template #addonBefore>
                <search-outlined /> 搜索:
              </template>
            </a-input>
          </a-col>
        </a-row>
        <a-table bordered :data-source="dataSourceNfsSheZhi" :columns="columnsNfsSheZhi" :pagination="paginationNfsSheZhi" class="y-table"></a-table>
      </a-card>
    </a-tab-pane>
  </a-tabs>
</template>

<script setup>
import windowsGongXiangQuanJuSheZhiModal from './modal/windowsGongXiangQuanJuSheZhiModal.vue'
import bianJiWindowsGongXiangModalfrom from './modal/bianJiWindowsGongXiangModal.vue'
import nfsShuChuModal from './modal/nfsShuChuModal.vue'
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
import { Modal } from 'ant-design-vue'
const activeKey = ref('sambaSheZhi')

// -- SAMBA设置
const visibleWindowsGongXiangQuanJuSheZhiModal = ref(false)

const openWindowsGongXiangQuanJuSheZhiModal = () => {
  visibleWindowsGongXiangQuanJuSheZhiModal.value = true
}

const visibleBianJiWindowsGongXiangModal = ref(false)

const openBianJiWindowsGongXiangModal = () => {
  visibleBianJiWindowsGongXiangModal.value = true
}

const tingZhiWindowsGongXiangFuwu = () => {
  Modal.confirm({
    title: '确认操作',
    icon: h(ExclamationCircleOutlined),
    content: '您确定要停止Windows共享服务?',
    okText: '确定',
    okType: 'danger',
    cancelText: '取消',
    onOk() {
      console.log('OK')
    },
    onCancel() {
      console.log('Cancel')
    }
  })
}

const searchValueSambaSheZhi = ref('')

// 表格列
const columnsSambaSheZhi = ref([
  {
    title: '共享名',
    dataIndex: 'name',
    key: 'name',
    align: 'center',
    sorter: {
      compare: (a, b) => a.name.localeCompare(b.name),
      multiple: 1
    }
  },
  {
    title: '用户',
    dataIndex: 'user',
    key: 'user',
    align: 'center',
    sorter: {
      compare: (a, b) => a.user.localeCompare(b.user),
      multiple: 2
    }
  },
  {
    title: '组',
    dataIndex: 'group',
    key: 'group',
    align: 'center',
    sorter: {
      compare: (a, b) => a.group.localeCompare(b.group),
      multiple: 3
    }
  },
  {
    title: '来源',
    dataIndex: 'laiYuan',
    key: 'laiYuan',
    align: 'center',
    sorter: {
      compare: (a, b) => a.laiYuan.localeCompare(b.laiYuan),
      multiple: 4
    }
  },
  {
    title: '登录时间',
    dataIndex: 'dengLuShiJian',
    key: 'dengLuShiJian',
    align: 'center',
    sorter: {
      compare: (a, b) => a.dengLuShiJian.localeCompare(b.dengLuShiJian),
      multiple: 5
    }
  },
  {
    title: '进程号',
    dataIndex: 'jinChengHao',
    key: 'jinChengHao',
    align: 'center',
    sorter: {
      compare: (a, b) => a.jinChengHao.localeCompare(b.jinChengHao),
      multiple: 6
    }
  }
])

// 表格数据
const dataSourceSambaSheZhi = ref([
  {
    key: '1',
    name: 'samba',
    user: 'admin',
    group: 'admin',
    laiYuan: 'samba',
    dengLuShiJian: '2021-09-20 17:00:00',
    jinChengHao: '1000'
  },
  {
    key: '2',
    name: 'samba',
    user: 'admin',
    group: 'admin',
    laiYuan: 'samba',
    dengLuShiJian: '2021-09-20 17:00:00',
    jinChengHao: '1000'
  }
])

// 分页
const paginationSambaSheZhi = {
  current: 1,
  pageSize: 10,
  showQuickJumper: true,
  showSizeChanger: true,
  total: 0,
  showTotal: (total, range) => {
    return `${range[0]}-${range[1]} 共 ${total} 条数据`
  },
  onChange: (page, pageSize) => {
    console.log('服务管理 > samba设置分页改变>>', page, pageSize)
  }
}

// -- NFS设置

const visibleNfsShuChuModal = ref(false)

const openNfsShuChuModal = () => {
  visibleNfsShuChuModal.value = true
}

const tingZhiUnixWenJianGongXiangFuWu = () => {
  Modal.confirm({
    title: '确认操作',
    icon: h(ExclamationCircleOutlined),
    content: '您确定要停止Unix文件共享服务?',
    okText: '确定',
    okType: 'danger',
    cancelText: '取消',
    onOk() {
      console.log('OK')
    },
    onCancel() {
      console.log('Cancel')
    }
  })
}

const searchValueNfsSheZhi = ref('')

// 表格列
const columnsNfsSheZhi = ref([
  {
    title: '目录',
    dataIndex: 'muLu',
    key: 'muLu',
    align: 'center',
    sorter: {
      compare: (a, b) => a.muLu.localeCompare(b.muLu),
      multiple: 1
    }
  },
  {
    title: '输出到...',
    dataIndex: 'shuChuDao',
    key: 'shuChuDao',
    align: 'center',
    sorter: {
      compare: (a, b) => a.shuChuDao.localeCompare(b.shuChuDao),
      multiple: 2
    }
  }
])

// 表格数据
const dataSourceNfsSheZhi = ref([
  {
    key: '1',
    muLu: '1',
    shuChuDao: '1'
  },
  {
    key: '2',
    muLu: '2',
    shuChuDao: '2'
  },
  {
    key: '3',
    muLu: '3',
    shuChuDao: '3'
  }
])

// 分页
const paginationNfsSheZhi = {
  current: 1,
  pageSize: 10,
  showQuickJumper: true,
  showSizeChanger: true,
  total: 0,
  showTotal: (total, range) => {
    return `${range[0]}-${range[1]} 共 ${total} 条数据`
  },
  onChange: (page, pageSize) => {
    console.log('服务管理 > nfs设置分页改变>>', page, pageSize)
  }
}
</script>

<style scoped lang='scss'>
.ant-row {
  margin-bottom: 10px;
}

.y-close-windows-gongXiang,
.y-close-windows-gongXiang:hover {
  color: red;
}
</style>